home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’91 / ColorHack 1991 / the hack / xxCSEARCH.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-21  |  882 b   |  73 lines  |  [TEXT/MPS ]

  1. #include "Types.h"
  2. #include "Resources.h"
  3.  
  4.     Boolean
  5. strcmpnum(ap,bp,len)
  6.     char    *ap;
  7.     char    *bp;
  8.     long    len;
  9.     {
  10.     Boolean    rc;
  11.     
  12.     rc = true;
  13.     
  14.     while (len > 0 && rc) {
  15.     if (*(ap++) != *(bp++))
  16.         rc = false;
  17.     len--;
  18.     }
  19.     
  20.     return rc;
  21.     }
  22.  
  23.  
  24.     pascal long
  25. CSEARCH(sp,sl,cp)
  26.     char    *sp;
  27.     long    sl;
  28.     char    *cp;
  29.     {
  30.     long    rc,ul;
  31.     Handle    scolH;
  32.     short    sh1,*shp;
  33.     char    *p1,uc;
  34.     Boolean    hit;
  35.     
  36.     scolH = GetResource('sCOL',128);
  37.     p1 = *scolH;
  38.     shp = (short *)p1;
  39.     sh1 = *shp;
  40.     hit = false;
  41.     p1 += 2;
  42.     while (sh1 > 0 && !hit)
  43.         {
  44.         uc = *(p1++);
  45.         
  46.         ul = uc;
  47.         if (ul == sl)
  48.             {
  49.             if (strcmpnum(sp,p1,ul))
  50.                 {
  51.                 p1 += ul;
  52.                 *(cp++) = *(p1++);
  53.                 *(cp++) = *(p1++);
  54.                 *(cp++) = *(p1++);
  55.                 *(cp++) = *(p1++);
  56.                 *(cp++) = *(p1++);
  57.                 *(cp++) = *(p1++);
  58.                 hit = true;
  59.                 }
  60.             }
  61.         if (!hit)
  62.             {
  63.             p1 += ul;
  64.             p1 += 6;
  65.             }
  66.         
  67.         sh1--;
  68.         }
  69.     if (hit) rc = 1; else rc = 0;
  70.     
  71.     return rc;
  72.     }
  73.